<%-- 
    Document   : donhang
    Created on : Dec 27, 2013, 8:36:35 AM
    Author     : home
--%>

<%@ page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page isErrorPage="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="t" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<t:layout>
    <jsp:body>
        <form:form action="updatehoadon" method="post" style="margin:0; padding:0" onsubmit="return verifyloginForm(this)" modelAttribute="hoadon">
        <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
                <td class="bgtitle"><table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
                        <tr>
                            <td width="20"><img src="<c:url value="/resources/images/mui_ten.gif" />"></td>
                            <td valign="bottom" class="title">Danh sách đơn đặt hàng</td>
                            <td width="10" valign="bottom">&nbsp;</td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td valign="top" >&nbsp;</td>
            </tr>
        </table>
        <table width='98%' align='center' border='0' cellpadding='2' cellspacing='0' style='border-collapse:collapse'>
            <tr>
                <td height='30' class='bgmenupro border3' bgcolor='#DDDDDD' width='5%'><div align='center'>
                        <strong>STT</strong>
                    </div>
                </td>
                <td class='bgmenupro border3' bgcolor='#DDDDDD' width='15%'>
                    <div align='center'>
                        <strong>Ngày đặt hàng</strong>
                    </div>
                </td>
                <td class='bgmenupro border3' bgcolor='#DDDDDD' width='20%'>
                    <div align='center'>
                        <strong>Mã đơn hàng</strong>
                    </div>
                </td>
                <td class='bgmenupro border3' bgcolor='#DDDDDD' width='20%'>
                    <div align='center'>
                        <strong>Tổng giá trị thanh toán</strong>
                    </div>
                </td>
                <td class='bgmenupro border3' bgcolor='#DDDDDD' >
                    <div align='center'>
                        <strong>Trạng thái</strong>
                    </div>
                </td>
                <td class='bgmenupro borderfull' bgcolor='#DDDDDD' width='15%'>
                    <div align='center'>
                        <strong>Ngày giao hàng</strong>
                    </div>
                </td>

            </tr>
            <!--load đơn hàng-->
            <c:forEach var="hoadon" varStatus="donhangCounter" items="${listHoaDon}">
                <tr>
                    <td class='border3'>
                        <div align='center'>${donhangCounter.count}</div>
                    </td>

                    <td class='border3'>
                        <div align='center'><fmt:formatDate pattern="dd-MM-yyyy hh:mm:ss" value="${hoadon.getNgayDatHang()}"/></div>
                    </td>
                    <td class='border3'>
                        <div align='center'>
                            <a href='<c:url value="/admin/chitiethoadon/${hoadon.getCodeHoaDon()}"/>' onclick="NewWindow(this.href, 'ThegioiKts', '900', '650', 'yes');
                                    return false">
                                <strong>${hoadon.getCodeHoaDon()}</strong>
                            </a>
                            <form:input path="CodeHoaDon" type="hidden" value="${hoadon.getCodeHoaDon()}"/>
                        </div>
                    </td>
                    <td class=' fontred fontsizecart border3'>
                        <div align='center'><fmt:formatNumber type="number" value="${hoadon.getTongTriGia()}"/> VND</div>
                    </td>
                    <td class=' fontsizecart border3'>
                        <div align='center'>
                            <form:select path="trangThaiHoaDon.maTthd">
                                <c:forEach var="tthd" varStatus="tthdCounter" items="${listTTHD}">
                                    <c:if test="${tthd.getMaTthd()==hoadon.getTrangThaiHoaDon().getMaTthd()}">
                                        <form:option value="${tthd.getMaTthd()}" selected="selected">${tthd.getTenTrangThaiHoaDon()}</form:option>
                                    </c:if>
                                    <c:if test="${tthd.getMaTthd()!=hoadon.getTrangThaiHoaDon().getMaTthd()}">
                                        <form:option value="${tthd.getMaTthd()}">${tthd.getTenTrangThaiHoaDon()}</form:option>
                                    </c:if>
                                </c:forEach> 
                            </form:select>
                        </div>
                    </td>
                    <td class='borderfull'>
                        

                                <form:input path="ngayGiaoHang" type="date" value="${hoadon.getNgayGiaoHang()}"/>

                         
                    </td>
                </tr>
            </c:forEach>
            <!--load xong -->
            <tr>
                <td colspan="7">
                    <br>
                    <div align='center'>
                        <input type="submit"/>
                        <input type="reset" >
                    </div>
                </td>
            </tr>

        </table>
    </form:form>
    <br />
    <!-- begin: popup!-->
    <script language="javascript">

        /*
         Auto center window script- Eric King (http://redrival.com/eak/index.shtml)
         Permission granted to Dynamic Drive to feature script in archive
         For full source, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
         */

        var win = null;
        function NewWindow(mypage, myname, w, h, scroll) {
            LeftPosition = (screen.width) ? (screen.width - w) / 2 : 0;
            TopPosition = (screen.height) ? (screen.height - h) / 2 : 0;
            settings =
                    'height=' + h + ',width=' + w + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll + ',resizable'
            win = window.open(mypage, myname, settings)
        }

    </script>
    <!-- end: popup!-->
    <!--loc-->
    </jsp:body>
</t:layout>